<?php

namespace App\Http\Transformers\Goods;

use League\Fractal\TransformerAbstract;
use App\Models\Goods;

class GetGoodsPageTransformer extends TransformerAbstract
{
    public function transform(Goods $goods)
    {
        $data = $goods->toArray();

        if($data['headImage']){
            data_set($data, 'headImage', \GuzzleHttp\json_decode($data['headImage']));
        }

        if($data['logo']){
            data_set($data, 'logo', \GuzzleHttp\json_decode($data['logo']));
        }

        return $data;
    }
}
